#include <bits/stdc++.h>
#define ll long long
#define db long double
#define N 200005
#define II pair <ll,ll>
#define III pair <ll,II>
#define IV pair <vector <int>,vector <int> >
#define fst first
#define snd second
using namespace std;
ll n,i,j,l,r,gt[N],ng[N],res,test;
const ll mod=round(1e9)+7;
ll lt(ll a,ll b)
{
if(b==0) return 1;
ll tg=lt(a,b/2);
return (b%2==0) ? tg*tg%mod : tg*tg%mod*a%mod;
}
ll C(int k,int n)
{
return (k<0 || k>n) ? 0 : gt[n]*ng[k]%mod*ng[n-k]%mod;
}
void solve()
{
cin>>n>>l>>r;
gt[0]=1;
for(i=1;i<=n;i++) gt[i]=gt[i-1]*i%mod;
ng[n]=lt(gt[n],mod-2);
for(i=n-1;i>=0;i--) ng[i]=ng[i+1]*(i+1)%mod;
res=0;
for(i=1;i<=n;i++)
{
j=max(r-i+l,1LL);
ll sum=0;
if(j<=i)
{
sum=C(n/2-n+i,i-j);
if(n&1) sum=(sum+C(n/2+1-n+i,i-j))%mod;
}
else if(j==i+1 && (n-i==n/2 || n-i==(n+1)/2))
sum=1;
res=(res+sum*(r-i))%mod;
}
for(i=1;i<=n;i++)
{
j=min(r-i+l-1,n);
ll sum=0;
if(j>=i)
{
sum=C(n/2-i+1,j-i);
if(n&1) sum=(sum+C(n/2+1-i+1,j-i))%mod;
}
else if(j==i-1 && (i-1==n/2 || i-1==(n+1)/2))
sum=1;
res=(res+sum*(i-l))%mod;
}
cout<<res<<'\n';
}
int main()
{
// freopen("ntu.inp","r",stdin);
// freopen("ntu.out","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin>>test;
while(test--) solve();
}
445. Add Two Numbers II | 442. Find All Duplicates in an Array |
437. Path Sum III | 436. Find Right Interval |
435. Non-overlapping Intervals | 406. Queue Reconstruction by Height |
380. Insert Delete GetRandom O(1) | 332. Reconstruct Itinerary |
368. Largest Divisible Subset | 377. Combination Sum IV |
322. Coin Change | 307. Range Sum Query - Mutable |
287. Find the Duplicate Number | 279. Perfect Squares |
275. H-Index II | 274. H-Index |
260. Single Number III | 240. Search a 2D Matrix II |
238. Product of Array Except Self | 229. Majority Element II |
222. Count Complete Tree Nodes | 215. Kth Largest Element in an Array |
198. House Robber | 153. Find Minimum in Rotated Sorted Array |
150. Evaluate Reverse Polish Notation | 144. Binary Tree Preorder Traversal |
137. Single Number II | 130. Surrounded Regions |
129. Sum Root to Leaf Numbers | 120. Triangle |